<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <!-- ##### 4、for-of

for-of 可以用来遍历的类型：

·for-of 循环用来遍历数据—-例如数组中的值

·for-of 循环不仅支持数组，还支持大多数类数组对象

·for-of 循环也支持字符串遍历，它将字符串视为一系列的 Unicode 字符来进行遍历

·它同样支持 Map 和 Set 对象遍历 -->

    <script>
        //遍历数组: 数组 set map
        let students = ["zhangsan", "lisi", "wangwu"];
        for (let i = 0; i < students.length; i++) {
            console.log(students[i]);
        }

        for (const student of students) {
            console.log(student);
        }

        //遍历集合 set 
        let names = new Set();
        names.add("你考上清华，他考上北大，我烤上红薯");
        names.add("zhangsan");
        names.add("lisi");
        for (var word of names) {
            console.log(word);
        }

        //遍历 map
        let phoneBookMap = new Map();
        phoneBookMap.set("zhangsan", "123456");
        phoneBookMap.set("lisi", "7654321");
        for (var [key, value] of phoneBookMap) {
            console.log(key + "'s phone number is: " + value);
        }
    </script>



</head>

<body>

</body>

</html>